<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function () {
            if (!checkForm(document.getElementById("saveForm"))) {
                return;
            }
            $("#btnSave").blur();
            showLoading();
            fy_api.ajaxSubmit($("#saveForm"),{
                success: function (data) {
                    hideLoading();
                    if (!isSuccess(data)) {
                        $.messager.alert('系统提示', data.msg, 'error', function () {
                            self.focus();
                        });
                    } else {
                        parent.grid_get("grid").datagrid("load");
                        turnBack();
                    }
                }
            });
        });
        var keyId = (getUrlParam("keyId", url));
        if(keyId != ""){
            //编辑
            fy_api.load_template({
                controller: $("#saveForm").attr("templateParam", "keyId=" + keyId), loading: true, initValue: true, loaded: function(){
                    loaded(keyId);
                }
            });
        }else{
            //添加
            $("#divEdit").remove();
            fy_api.load_template({
                controller: $("#saveForm").attr("templateParam", "keyId=" + keyId), loading: true,initValue: true, loaded: function(){
                    loaded(keyId);
                    $("#saveForm").attr("action","project/save.do")
                }
            });
        }
    });
    function loaded(keyId){
        //所属服务器
        $('#server').inputgrid({
            idField:'o.id',
            textField:'o.outerIp',
            multiple: false,
            searchField:['o.id','o.outerIp'],//查询字段多字段匹配
            queryParamsFun:function(input){
                var param = [{field: 'o.deleteFlag', value: '0' }];
                return param;
            },
            columns:[[
                { field: 'o.id', title: '编号',width:60},
                { field: 'o.outerIp', title: '服务器IP',width:120 }
            ]],
            _page: parent.page_list,
            _append: [],//隐藏列
            _table: "bs_servers o"
        });

    }
    function turnBack() {
        parent.j_closeWin();
    }
</script>
<form action="project/update.do" method="post" id="saveForm" templateUrl="project/get.do">
    <div id="divEdit">
        <input type="hidden" name="id" value="${id}"/>
        <input type="hidden" name="deleteFlag" value="${deleteFlag}"/>
    </div>
    <table style="margin: 10px auto;border: 1px solid darkgrey;padding: 10px">
        <tr>
            <td>
                <div class="div-label"><span class="nullTip">*</span>项目中文名称：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="项目中文名称" name="cnName" value="${cnName}" />
                </div>
            </td>
            <td>
                <div class="div-label">项目英文名称：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" name="enName" value="${enName}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label"><span class="nullTip">*</span>访问地址：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="访问地址" name="url" value="${url}" />
                </div>
            </td>
            <td>
                <div class="div-label"><span class="nullTip">*</span>所属服务器IP：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="hidden" name="server.id" value="${server.id}" />
                    <input type="text" isNull="所属服务器IP" id="server" value="${server.outerIp}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label"><span class="nullTip">*</span>所属服务器路径：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="所属服务器路径" name="serverPath" value="${serverPath}" />
                </div>
            </td>
            <td>
                <div class="div-label"><span class="nullTip">*</span>数据库地址：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="数据库地址" name="dbUrl" id="dbUrl" value="${dbUrl}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label"><span class="nullTip">*</span>数据库用户名：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="数据库用户名" name="dbUser" id="dbUser" value="${dbUser}" />
                </div>
            </td>
            <td>
                <div class="div-label"><span class="nullTip">*</span>数据库密码：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="数据库密码" name="dbPass" value="${dbPass}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label"><span class="nullTip">*</span>金融代码：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="金融代码" name="financialCode" value="${financialCode}" />
                </div>
            </td>
            <td>
                <div class="div-label"><span class="nullTip">*</span>金融代码密码：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" isNull="金融代码密码" name="pass" value="${pass}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label">启动地址：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" name="startUpUrl" value="${startUpUrl}" />
                </div>
            </td>
            <td>
                <div class="div-label">终止地址：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" name="shutDownUrl" value="${shutDownUrl}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="div-label">状态：</div>
            </td>
            <td>
                <div class="div-item">
                    <select name="useFlag" id="useFlag" style="width: 160px;" value="${useFlag}" >
                        <option value="1" >启用</option>
                        <option value="0" >禁用</option>
                    </select>
                </div>
            </td>
            <td>
                <div class="div-label">备注：</div>
            </td>
            <td>
                <div class="div-item">
                    <input type="text" name="remark" id="remark" value="${remark}" style="width: 95%"/>
                </div>
            </td>
        </tr>
    </table>
</form>
<div class="form-buttons">
    <a id="btnSave" class="easyui-linkbutton" iconCls="icon-save">保存</a>
    <a id="btnBack" class="easyui-linkbutton c2" iconCls="icon-undo" onClick="turnBack();">返回</a>
</div>